package com.malou.server.ventas.cajainicial;

import java.sql.SQLException;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.malou.client.ventas.cajainicial.CajaInicial;
import com.malou.server.base.Conexion;

public class CajaIniciales {
	
	public static SqlMapClient sqlMap = null;
	public static Integer errorTipo = 0;
	
	public static Double getCajaInicial(CajaInicial ci){
		sqlMap = Conexion.getSqlMap();  
		CajaInicial obj =null;
		
		try {			
	        
	        obj = (CajaInicial) sqlMap.queryForObject("getIdCajaInicial", ci);
	    	
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return obj.getSaldoinicial();
	}
	
	public static boolean save(CajaInicial ci){
		boolean retorno = true;		   
	
		sqlMap = Conexion.getSqlMap();
		try {
			if(ci!=null){
				sqlMap.insert("insertCajaInicial", ci);
			}else{
				errorTipo = 1; // Ya existe una caja inicial
				retorno = false;
			}
		} catch (SQLException e) {
			retorno = false;			
			e.printStackTrace();
		}
		return retorno;
	}
	
	
}
